package com.huayun.dcsp.service1.web;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.huayun.dcsp.service1.model.*;
import com.huayun.dcsp.service1.service.*;
import com.huayun.dcsp.service1.model.Student;

@RestController  
@RequestMapping("/students") 
public class StudentController {
	
	@Autowired
	private StudentService studentService;
	

	@RequestMapping(value = "/all", method = RequestMethod.GET)   
    public  List<Student> getAllStudents(HttpServletRequest req) {   
        System.out.println("students:all");

        List<Student> list=studentService.getAllStudents();
        return list;
    }  
	
	@RequestMapping(value = "/Id/{studentid}", method = RequestMethod.GET)   
	public  Student getStudent(HttpServletRequest req,
			@PathVariable("studentid") String studentId) {   
		System.out.println("get: "+studentId);
	          
	    return studentService.getStudent(studentId);
	}   

}
